from processing.model.component import Component
from processing.shape.dynamic_shape import DynamicShape
from processing.shape.drawers import CircleDrawer
from processing.shape.static_shape import StaticShape
from processing.shape.description import Description
from processing.shape.color import dark, color
from processing.model.instruction import Instruction
from processing.model.flow_component import FlowComponent


class ProcessingCPU(FlowComponent):
    
    def __init__(self):
        FlowComponent.__init__(self)
        self.enter_position(-30, 10)
        self.exit_position(-30, 40)
        self.x = 600
        self.y = 200
        
    def on_added(self):
        FlowComponent.on_added(self)
        self.running = DynamicShape(self, CircleDrawer, [60, 40, 20], [color.yellow, color.orange, color.red])
        self.stoped  = StaticShape(self, CircleDrawer,  [60, 50    ], [color.red   , dark.red])
        self.render  = self.stoped       
        self.add(Description("CPU", 30, 80, color.cyan, 10))
  
    def run_instruction(self):
        self.add(Instruction(20, 20))
  
    def update(self):
        FlowComponent.update(self)
        self.render.update()
        
    def draw(self):
        FlowComponent.draw(self)
        self.render.draw()
        
    def stop(self):
        self.render = self.stoped
        
    def run(self):
        self.render = self.running
    